Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to Pixi, Hatchling, Pre-commit, and Ruff #142

Merged
merged 36 commits into from
Aug 7, 2024
Merged

Move to Pixi, Hatchling, Pre-commit, and Ruff #142

merged 36 commits into from
Aug 7, 2024

Conversation

hoxbro
Copy link
Member

@hoxbro hoxbro commented Aug 4, 2024

I have temporarily added upper pins to pandas, pyarrow, and geopandas. This is so the tests can pass in this PR, and we can, in follow-up PRs, tackle the individual packages upgrade.

For now, I have only added a smaller set of pre-commit and ruff settings; this, again, can be expanded in other PRs.

I also added support for Python 3.12 and Moto 5.

Supersedes #135
Fixes #93

@hoxbro hoxbro changed the title Move to Pixi and Hatchling Move to Pixi, Hatchling, Pre-commit, and Ruff Aug 4, 2024
hooks:
- id: ruff
files: datashader/
- repo: https://github.com/hoxbro/clean_notebook
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we should add this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think so, at least for now. The examples notebooks are deliberately checked in with the output.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have restored the output of the notebooks

@hoxbro
Copy link
Member Author

hoxbro commented Aug 4, 2024

Difference in build:

                                   Spatialpandas - wheel
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Files only in run 1                       ┃ Files only in run 2                         ┃
┃ spatialpandas 0.4.10 py2.py3 none any.whl ┃ spatialpandas 0.4.11a2.post1.dev19+g1f46a13 ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ $VERSION.dist-info/LICENSE                │ $VERSION.dist-info/licenses/LICENSE         │
│ $VERSION.dist-info/top_level.txt          │ $VERSION.dist-info/licenses/NOTICE          │
│ spatialpandas/.version                    │ spatialpandas/__version.py                  │
│ -                                         │ spatialpandas/_version.py                   │
└───────────────────────────────────────────┴─────────────────────────────────────────────┘
                                                   Spatialpandas - sdist
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Files only in run 1                                  ┃ Files only in run 2                                              ┃
┃ spatialpandas 0.4.10                                 ┃ spatialpandas 0.4.11a2.post1.dev19+g1f46a13                      ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ $VERSION/CHANGELOG.md                                │ $VERSION/.gitignore                                              │
│ $VERSION/MANIFEST.in                                 │ $VERSION/examples/Overview.ipynb                                 │
│ $VERSION/setup.cfg                                   │ $VERSION/examples/Polygon-Array-Construction-From-Exterior.ipynb │
│ $VERSION/setup.py                                    │ $VERSION/scripts/conda/build.sh                                  │
│ $VERSION/spatialpandas.egg-info/PKG-INFO             │ $VERSION/scripts/conda/recipe/meta.yaml                          │
│ $VERSION/spatialpandas.egg-info/SOURCES.txt          │ $VERSION/spatialpandas/__version.py                              │
│ $VERSION/spatialpandas.egg-info/dependency_links.txt │ $VERSION/spatialpandas/_version.py                               │
│ $VERSION/spatialpandas.egg-info/requires.txt         │ -                                                                │
│ $VERSION/spatialpandas.egg-info/top_level.txt        │ -                                                                │
│ $VERSION/spatialpandas/.version                      │ -                                                                │
└──────────────────────────────────────────────────────┴──────────────────────────────────────────────────────────────────┘
                                             Spatialpandas - conda #1
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Files only in run 1                                         ┃ Files only in run 2                               ┃
┃ spatialpandas 0.4.10                                        ┃ spatialpandas 0.4.11a2.post1.dev19+g1f46a13       ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ site-packages/$VERSION-py3.12.egg-info/PKG-INFO             │ info/test/run_test.bat                            │
│ site-packages/$VERSION-py3.12.egg-info/SOURCES.txt          │ info/test/run_test.sh                             │
│ site-packages/$VERSION-py3.12.egg-info/dependency_links.txt │ info/test/test_time_dependencies.json             │
│ site-packages/$VERSION-py3.12.egg-info/requires.txt         │ site-packages/$VERSION.dist-info/INSTALLER        │
│ site-packages/$VERSION-py3.12.egg-info/top_level.txt        │ site-packages/$VERSION.dist-info/METADATA         │
│ site-packages/spatialpandas/.version                        │ site-packages/$VERSION.dist-info/RECORD           │
│ -                                                           │ site-packages/$VERSION.dist-info/REQUESTED        │
│ -                                                           │ site-packages/$VERSION.dist-info/WHEEL            │
│ -                                                           │ site-packages/$VERSION.dist-info/direct_url.json  │
│ -                                                           │ site-packages/$VERSION.dist-info/licenses/LICENSE │
│ -                                                           │ site-packages/$VERSION.dist-info/licenses/NOTICE  │
│ -                                                           │ site-packages/spatialpandas/__version.py          │
│ -                                                           │ site-packages/spatialpandas/_version.py           │
└─────────────────────────────────────────────────────────────┴───────────────────────────────────────────────────┘

@hoxbro hoxbro marked this pull request as ready for review August 4, 2024 16:40
@hoxbro
Copy link
Member Author

hoxbro commented Aug 4, 2024

This PR is in a good state.

There are still some edge cases, as shown by the hypothesis tests, but I will say that is out of scope for this PR.

]
dependencies = ['dask', 'fsspec >=2022.8', 'numba', 'pandas', 'pyarrow >=10', 'retrying']
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added lower pins to fsspec and pyarrow, as it could give bad solves in CI.

@@ -11,7 +11,7 @@

hyp_settings = settings(
deadline=None,
max_examples=500,
max_examples=100,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reduced this to 100.

@hoxbro
Copy link
Member Author

hoxbro commented Aug 5, 2024

Two cases failing with Hypothesis, will open an issue after this PR has been merged. Both seems to be related to strict comparison.

For test_segment_intersection, we could add a skip if it is not a line but a point. I have done that in c3b2b56.

# Failing: test_multipolygon_cx_selection
import geopandas as gpd
from shapely.geometry import shape
from spatialpandas.geometry import MultiPolygonArray

geometry = {
    "type": "MultiPolygon",
    "coordinates": [
        [
            [
                [-40.584103603229096, -3.6817177099899876],
                [-25.93909571878391, 27.960034115881996],
                [-29.06279226754736, 50.0],
                [-2.0859372955624726, 50.0],
                [2.491304910804627, 32.34563365363812],
                [15.039797653702573, 31.198711405699328],
                [22.789773854429544, 19.718458404794436],
                [50.0, 20.800773018225026],
                [50.0, 10.074395460794436],
                [16.96014963061812, -28.981388627755035],
                [8.698742846075964, -47.44958665067525],
                [-15.177316735436102, -19.715134610036017],
                [-40.584103603229096, -3.6817177099899876],
            ]
        ]
    ],
}
gp_multipolygon = gpd.GeoSeries([shape(geometry)])
xslice, yslice = (slice(None, 0.0, None), slice(50.0, None, None))  # Works if slice is 50.0000001
expected = MultiPolygonArray.from_geopandas(gp_multipolygon.cx[xslice, yslice])
result = MultiPolygonArray.from_geopandas(gp_multipolygon).cx[xslice, yslice]
assert all(expected == result)
# Failing: test_segment_intersection
from shapely import geometry as sg
from spatialpandas.geometry._algorithms.intersection import segments_intersect

ax0, ay0, ax1, ay1, bx0, by0, bx1, by1 = 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, -1.0, -1.0

result = segments_intersect(ax0, ay0, ax1, ay1, bx0, by0, bx1, by1)

line1 = sg.LineString([(ax0, ay0), (ax1, ay1)])
line2 = sg.LineString([(bx0, by0), (bx1, by1)])
expected = line1.intersects(line2)
assert result == expected

@hoxbro hoxbro requested a review from philippjfr August 5, 2024 09:27
@philippjfr philippjfr merged commit 0a2c22c into main Aug 7, 2024
11 checks passed
@philippjfr philippjfr deleted the pixi branch August 7, 2024 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set up code coverage
2 participants